package cn.icanci.ladybird.service.impl;

import cn.icanci.ladybird.pojo.entity.TicketAddress;
import cn.icanci.ladybird.dao.TicketAddressDao;
import cn.icanci.ladybird.service.TicketAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TicketAddress)表服务实现类
 *
 * @author makejava
 * @since 2020-09-29 20:43:41
 */
@Service("ticketAddressService")
public class TicketAddressServiceImpl implements TicketAddressService {
    @Resource
    private TicketAddressDao ticketAddressDao;

    /**
     * 通过ID查询单条数据
     *
     * @param ticketAddressId 主键
     * @return 实例对象
     */
    @Override
    public TicketAddress queryById(Long ticketAddressId) {
        return this.ticketAddressDao.queryById(ticketAddressId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TicketAddress> queryAllByLimit(int offset, int limit) {
        return this.ticketAddressDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ticketAddress 实例对象
     * @return 实例对象
     */
    @Override
    public TicketAddress insert(TicketAddress ticketAddress) {
        this.ticketAddressDao.insert(ticketAddress);
        return ticketAddress;
    }

    /**
     * 修改数据
     *
     * @param ticketAddress 实例对象
     * @return 实例对象
     */
    @Override
    public TicketAddress update(TicketAddress ticketAddress) {
        this.ticketAddressDao.update(ticketAddress);
        return this.queryById(ticketAddress.getTicketAddressId());
    }

    /**
     * 通过主键删除数据
     *
     * @param ticketAddressId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long ticketAddressId) {
        return this.ticketAddressDao.deleteById(ticketAddressId) > 0;
    }
}